import { createFileRoute } from '@tanstack/react-router'
import Uploads from '@/features/uploads'
import { dictGet } from '@/api/dicts'
import { DictValue } from '@/features/dicts/data/schema'

export const Route = createFileRoute('/_authenticated/uploads/')({
  component: Uploads,
  loader: async ({ context: { queryClient } }): Promise<{ uploadDict: DictValue[] }> => {
    const uploadDictRes = await queryClient.fetchQuery({
      queryKey: ['dicts', 'upload'],
      queryFn: () => dictGet('upload'),
    })
    return { uploadDict: uploadDictRes.data.data }
  }
})
